<?php
    if(!empty($contasPagar)): ?>
        <thead>
        <tr>
            <th class="col-md-4 vert-align">
                <div class="ckbox ckbox-danger">
                    <input type="checkbox" onchange="check_all(this)" name="check_all" class="sa-chk-ContasPagar-checkAll" id="check_all" />
                    <label for="check_all">DESCRIÇÃO</label>
                </div>
            </th>
            <th class="col-md-2 vert-align">VALOR A PAGAR</th>
            <th class="col-md-2 vert-align">VALOR PAGO</th>
            <th class="col-md-1 vert-align text-left">DATA</th>
            <th class="col-md-1 text-center">OPÇÕES</th>
            <th class="col-md-1 text-center">RECEBER</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($contasPagar as $contaPagar): ?>
            <tr id="sa-tr-ContasPagar-<?php echo $contaPagar['PayReceive']['id'] ?>">
                <td class="vert-align">
                    <div class="ckbox ckbox-danger">
                        <input type="checkbox" onchange="somarValor(this)" name="conta_<?php echo $contaPagar['PayReceive']['id'] ?>" value="<?php echo $contaPagar['PayReceive']['id'] ?>" data-value="<?php echo $contaPagar['PayReceive']['valor_doc'] ?>" id="<?php echo $contaPagar['PayReceive']['id'] ?>" class="sa-chk-ContasPagar-valorConta" />
                        <label for="<?php echo $contaPagar['PayReceive']['id'] ?>"><?php echo $contaPagar['Account']['name'] ?> - <?php echo $contaPagar['PayReceive']['descricao'] ?></label>
                    </div>
                </td>
                <td class="vert-align">
                    R$ <?php echo $this->Func->money($contaPagar['PayReceive']['valor_liquido']) ?>
                </td>
                <td class="vert-align">
                    R$ <?php echo $this->Func->money($contaPagar['PayReceive']['valor_pago']) ?>
                </td>
                <td class="vert-align text-left">
                    <label for="<?php echo $contaPagar['PayReceive']['id'] ?>" class="label label-<?php echo $this->Func->ativaContaVencida($contaPagar['PayReceive']['data_vencimento'],$contaPagar['PayReceive']['data_pagamento']); ?>"><?php echo $this->Func->DateFormat(array('date'=>$contaPagar['PayReceive']['data_vencimento'],'type'=>'2','time'=>false)); ?></label>
                </td>
                <td class="vert-align text-center">
                    <div class="btn-group nomargin">
                        <?php if($contaPagar['PayReceive']['data_pagamento'] == null): ?>
                            <?php echo $this->Html->link('<i class="fa fa-pencil"></i>','javascript:;',array("class"=>"btn btn-white btn-xs",'escape'=>false,"title"=>"Editar Registro",'onclick'=>'editContaPagar('.$contaPagar['PayReceive']['id'].')')); ?>

                            <?php echo $this->Form->postLink('<i class="fa fa-trash-o"></i>', array('action' => 'delete', $contaPagar['PayReceive']['id']), array('escape'=>false,"title"=>"Excluir","class"=>"btn btn-danger btn-xs"), __('Deseja realmente excluir este lançamento# %s?', $contaPagar['Account']['name'])); ?>
                        <?php endif; ?>
                    </div>
                </td>
                <td class="vert-align text-center">
                    <?php echo $this->Func->btnPagar(array('id'=>$contaPagar['PayReceive']['id'],'Mes'=>$Mes),$contaPagar['PayReceive']['data_pagamento']); ?>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    <?php else: ?>
        <tr>
            <td>
                <div class="alert alert-info mb5">
                    <strong>INFORMÇÃO:&nbsp;</strong><span>Não foi encontrado resultado para o mês:  <strong><?php echo $Mes."/".$Ano ?></strong></span>
                </div>
            </td>
        </tr>
    <?php endif; ?>